import _fetch from './request'
function apiGetCode (mobile) {
  return _fetch({
    url: '/au/code',
    method: 'post',
    data: {
      mobile: mobile
    }
  })
}
// 登录
function toLogin ({ mobile, code }) {
  return _fetch({
    url: '/au/login',
    method: 'post',
    data: {
      mobile,
      code
    }
  })
}
// 获取用户信息
function apiGetUserInfo () {
  return _fetch({
    url: '/au/info',
    // headers: {
    //   authorization: 'Bearer ' + value
    // }
    needToken: true
  })
}
// 修改用户信息
function apiEditUserInfo ({ nickname, intro, gender, avatar, position, area }) {
  return _fetch({
    url: '/au/edit',
    needToken: true,
    method: 'POST',
    data: {
      nickname,
      intro,
      gender,
      avatar,
      position,
      area
    }
  })
}
// 上传图片到服务器
function uploadImg (file) {
  // 创建一个formDate   对象
  const fd = new FormData()
  fd.append('files', file)
  return _fetch({
    url: '/upload',
    method: 'POST',
    needToken: true,
    data: fd
  })
}
export { apiGetCode, toLogin, apiGetUserInfo, apiEditUserInfo, uploadImg }
